<?php
if(!defined('DEDEINC')) exit("Request Error!");

require_once(LIB.'/datalistcp.class.php');
/**
 *问答模块 注册后台控制器
 * by zsh
 */

class register extends Control{

    function register(){
        parent::__construct();
        $this->style = 'admin';
        $this->mregister = $this->Model('mregister');
    }

    function ac_index(){
        $search = request("search","");
        $sql = "select id,email,userName,phone,dateGraduate,schoolGraduate,education,schoolChoose,updateTime,status from `#@__guanjun_register` ";
        if($search == "search"){// 若是搜索调用则拼装search sql
            $keyword = request("keyword","") == "" ? "" : " where title like '%" . request("keyword","") . "%'";
            if($keyword != ""){
                $sql .= $keyword;
            }

            $order = request("order","");
            $attribution = request("attribution","");
            if( $order != "" && $attribution != ""){
                $orderby = " order by " . $attribution ." DESC, " . $order . " DESC";
                $sql .= $orderby;
            }else if($order != "" || $attribution != ""){
                 // $order = $order == "" ? "" : $order . " DESC";
                // $attribution = $attribution == "" ? "" : $attribution . " DESC";
                $orderby = " order by " . $order ." " . $attribution . "DESC";
                $sql .= $orderby;
            }

        }


        $rdl = new DataListCP();
        $rdl->pageSize = 10;              //设定每页显示记录数（默认25条）
        // $dl->style='admin';
        $rdl->SetParameter('ct',"register");
        $rdl->SetTemplate(DEDEWENDA.'/templates/admin/register_list.htm');      //载入模板
        $rdl->SetSource($sql);            //设定查询SQL

        $rdl->Display();
    }

    function ac_register_delete(){
        $id = intval(request("id",""));
        $sql = "delete from `#@__guanjun_register` where id = $id";
        $this->mregister->register_query($sql);
        ShowMsg("删除成功!","?wenda&ct=register");
    }

    function ac_check_status(){
        $id =  intval(request("id",""));
        $where = "id = " . $id;
        $data = $this->mregister->register_get_one($where);
        $status = $data['status'] == 0 ? 1 : 0;
        $this->mregister->register_query("update `#@__guanjun_register` set status=" . $status . " where id=" . $id);
    }

}

?>